package org.serverct.finalfight.internal.game.morerecipes;

import org.bukkit.Bukkit;
import org.bukkit.NamespacedKey;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.inventory.Recipe;
import org.bukkit.scheduler.BukkitRunnable;
import org.serverct.finalfight.FinalFight;

public abstract class BasicRecipe {
    public int limit;
    public NamespacedKey key;
    public Recipe recipe;
    public RecipeType type;
    public RecipeCategory category;

    public BasicRecipe(YamlConfiguration yaml) {
        key = new NamespacedKey(FinalFight.plugin, yaml.getString("key"));
        limit = yaml.getInt("limit");
        type = RecipeType.valueOf(yaml.getString("type"));
        category = RecipeCategory.valueOf(yaml.getString("category"));

        new BukkitRunnable() {
            @Override
            public void run() {
                Bukkit.removeRecipe(key);
                Bukkit.addRecipe(recipe);
            }
        }.runTaskLater(FinalFight.plugin, 2L);
    }
}
